home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Report Writers / Crystal Repot 9.0 Full CD version / Setup.exe / ProgramF / CRYSTAL / CRW9 / DEV / INCLUDE / Ufmain.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-01-17  |  4.1 KB  |  171 lines

  1. /*
  2. ** File:    UFMain.c
  3. ** Author:  Rick Cameron, Rex Benning
  4. ** Date:    7 Mar 93
  5. **
  6. ** Purpose: The main file for a user-defined function DLL.
  7. */
  8.  
  9. #include <Windows.h>
  10. #include "UFDll.h"
  11. #include "UFFuncs.h"
  12. #include "UFMain.h"
  13. #include "UFUser.h"
  14.  
  15.  
  16. HINSTANCE UFInstance = 0;
  17.  
  18. UF5FunctionDefStringList FunctionDefStringList =
  19. {
  20.        {sizeof (UF5FunctionDefStringList)},
  21.        {FunctionDefStrings}
  22. };
  23.  
  24. UFFunctionTemplateList FunctionTemplateList =
  25. {
  26.        {sizeof (UFFunctionTemplateList)},
  27.        {FunctionTemplates}
  28. };
  29.  
  30. UFFunctionExampleList FunctionExampleList =
  31. {
  32.        {sizeof (UFFunctionExampleList)},
  33.        {FunctionExamples}
  34. };
  35.  
  36. #if defined (WIN32)
  37. BOOL WINAPI DllMain (HINSTANCE hInstance, ULONG reson_for_call, LPVOID lpReserved)
  38. {
  39.     UFInstance = hInstance;
  40.     return TRUE;
  41. }
  42. #else
  43.  
  44. int FAR PASCAL LibMain (HINSTANCE hInstance,
  45.                         WORD      wDataSeg,
  46.                         WORD      cbHeapSize,
  47.                         LPSTR     lpCmdLine)
  48. {   
  49.     UFInstance = hInstance;
  50.  
  51.     return TRUE;
  52. }
  53.  
  54. int FAR PASCAL WEP (int nParam)
  55. {
  56.     return 1;
  57. }
  58. #endif  
  59.  
  60. ExternC UFError CR_EXPORT UF5Initialize (CRVersion crVersion)
  61. {
  62.     return crVersion >= CurVersionNumber ? UFNoError : UFUserError;
  63. }
  64.  
  65. ExternC UFTInt16u CR_EXPORT UFGetVersion ()
  66. {                           
  67.     return CurVersionNumber;
  68. }
  69.  
  70. ExternC UFError CR_EXPORT UFTerminate ()
  71. {
  72.     return (UFNoError);
  73. }
  74.  
  75. ExternC UFFunctionTemplateList FAR * CR_EXPORT UFGetFunctionTemplates ()
  76. {
  77.     return (&FunctionTemplateList);
  78. }
  79.  
  80. ExternC UFFunctionExampleList FAR * CR_EXPORT UFGetFunctionExamples ()
  81. {
  82.     return (&FunctionExampleList);
  83. }
  84.  
  85. ExternC UF5FunctionDefStringList FAR * CR_EXPORT UF5GetFunctionDefStrings ()
  86. {
  87.     return (&FunctionDefStringList);
  88. }
  89.  
  90. ExternC char FAR * CR_EXPORT UFErrorRecovery (UFParamBlock FAR *paramPtr,
  91.                                       UFError errN)
  92. {
  93.     return ErrorTable [(UFTInt16u)paramPtr->ReturnValue.UFReturnUserError];
  94. }
  95.  
  96. ExternC void CR_EXPORT UFStartJob (UFTInt32u jobId)
  97. {
  98.     // initialize any job-related data structures
  99.     InitForJob (jobId);
  100. }
  101.  
  102. ExternC void CR_EXPORT UFEndJob (UFTInt32u jobId)
  103. {
  104.     // clean up any job-related data structures
  105.     TermForJob (jobId);
  106. }
  107.  
  108.  
  109. /* GetParam
  110. ** This is a routine internal to the DLL. It should be copied into every
  111. ** DLL as a standard access to the parameter block.
  112. */
  113.  
  114. UFParamListElement FAR *GetParam (UFParamBlock FAR *Param,
  115.                                   UFTInt16s ParamNumber)
  116. {
  117.     UFParamListElement FAR *ParamPtr = Param->UFParamList;
  118.  
  119.     while (--ParamNumber && (ParamPtr != NULL))
  120.         ParamPtr = ParamPtr->NextParam;
  121.  
  122.     return ParamPtr;
  123. }
  124. /* GetMemCalcParam
  125. ** This routine gets the parameters from the list passed to memory allocation
  126. ** (string length or array size) calculation routine.
  127. */
  128.  
  129. UFMemCalcParam FAR *GetMemCalcParam (UFMemCalcBlock FAR *Param,
  130.                                      UFTInt16s ParamNumber)
  131. {
  132.     UFMemCalcParam FAR *ParamPtr = Param->UFMemCalcParamList;
  133.  
  134.     while (--ParamNumber && (ParamPtr != NULL))
  135.         ParamPtr = ParamPtr->NextMemCalcParam;
  136.  
  137.     return ParamPtr;
  138. }
  139.  
  140. /* GetMemCalcParam
  141. ** This routines gets array-element sub-arguments from the chain
  142. ** of arguments passed to the memory calculation routines.
  143. */
  144.  
  145. UFMemCalcParam FAR *GetMemCalcArrayElement (UFMemCalcParam FAR *Param,
  146.                                             UFTInt16s ParamNumber)
  147. {
  148.     UFMemCalcParam FAR *ParamPtr = Param->MemCalcParameter.MemCalcSubParam;
  149.  
  150.     while (--ParamNumber && (ParamPtr != NULL))
  151.         ParamPtr = ParamPtr->NextMemCalcParam;
  152.  
  153.     return ParamPtr;
  154. }
  155.  
  156. /* GetMemCalcRunParam
  157. ** This is a routine internal to the DLL. It should be copied into every
  158. ** DLL as a standard access to the parameter block.
  159. */
  160.  
  161. UFParamListElement FAR *GetMemCalcRunParam (UFMemCalcBlock FAR *Param,
  162.                                             UFTInt16s ParamNumber)
  163. {
  164.     UFParamListElement FAR *ParamPtr = Param->UFParamList;
  165.  
  166.     while (--ParamNumber && (ParamPtr != NULL))
  167.         ParamPtr = ParamPtr->NextParam;
  168.  
  169.     return ParamPtr;
  170. }
  171.